﻿using AppMVVM.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AppMVVM.Views
{
    /// <summary>
    /// Interaction logic for ArticleListView.xaml
    /// </summary>
    public partial class ArticleListView : UserControl
    {
        private ArticleView _articlePage;

        public ArticleListView()
        {
            _articlePage = new ArticleView();

            InitializeComponent();
        }
        public void Selector_OnSelectionChange(object sender, SelectionChangedEventArgs e)
        {
            Article article = e.AddedItems as Article;

            if (article != null)
            {
                this.htmlContent.Content = _articlePage;
                this.htmlContent.DataContext = article;
            }
        }
        private void ListViewItem_PreviewMouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            var article = (sender as ListView).SelectedItem as Article;

            if (article != null)
            {
                this.htmlContent.Content = _articlePage;
                this.htmlContent.DataContext = article;
            }
        }
    }
}
